package com.tingyuge.base.thread.wang.chapter6;

/**
 * 线程中断
 */
public class ThreadClose {

    public static class Worker extends Thread{
        private volatile boolean start = true;

        @Override
        public void run() {
            while (start){

            }
        }
        public void shutdown(){
            this.start=false;
        }
    }

    public static void main(String[] args) {
        Worker worker = new Worker();
        worker.start();
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();

        }

        worker.shutdown();
    }
}
